Hello all, I am new to DOORS DXL scripting.I have an requirement I have written a dxl script to run in open module.If the script is not running in open module, start.bat should be called. In start.bat , we will be predefining the following,
Any pointers will be useful Best Regards, Brindha brindhaMano - Thu Sep 11 08:13:37 EDT 2014 |
Re: Calling batch file from DXL script Why call start.bat to open the module? Why not just do it in the dxl script? You can easily open a file (.txt, .csv, etc.) and read it in, line by line and act on it with the dxl script. Greg |
Re: Calling batch file from DXL script GregM_dxler - Thu Sep 11 08:49:39 EDT 2014 Why call start.bat to open the module? Why not just do it in the dxl script? You can easily open a file (.txt, .csv, etc.) and read it in, line by line and act on it with the dxl script. Greg Hello Greg, Thanks for your response.But I need batch file because the text file name and location can be changed everytime only in the batch file and the dxl script need not be altered. Please help me with this requirement. Best Regards, Brindha |
Re: Calling batch file from DXL script
Did you already checkout the foum search? Maybe it helps, regards, Mathias |
Re: Calling batch file from DXL script Mathias Mamsch - Mon Sep 15 05:01:07 EDT 2014
Did you already checkout the foum search? Maybe it helps, regards, Mathias Hello Mathias, I already found the above thread and it was helpful.But my problem is, I am creating a dxl script with two tabs, one is for choosing the attribute values to be copied to a .txt file and the other tab is for importing the txt file and copying the same to choosen attributes with GUI. Now my requirement is , to run script in batch mode with functionality of second tab.Once the script opens it checks Open module ----> GUI mode as usual Not in module (may be from project/folder) ------>run start.bat , in that valid module and the text file to be read should be given and copying of attributes functionality should perform in the module configured in start.bat by reading the text file. I could not find a sample of this function.Please help me To be more clear on my requirement,
if (null current Module) { 1. I don't know how to call batch file from dxl script.What i found in all forums is all about starting a dxl script with a batch file,but i need to know the reverse too for my implementation. 2.In dxl reference also, there is no much information about batch mode :( In start.bat, following details should be pre-configured, 1. Valid module name where copying of attribute values needs to be done 2. Text file location from where attribute values to be copied 3.Log file should be created for capturing all actions done in batch mode with date and time. I am a beginner to Dxl and this is my first script .Kindly help me with your valuable suggestions.
Best Regards, Brindha |
Re: Calling batch file from DXL script brindhaMano - Mon Sep 15 07:22:57 EDT 2014 Hello Mathias, I already found the above thread and it was helpful.But my problem is, I am creating a dxl script with two tabs, one is for choosing the attribute values to be copied to a .txt file and the other tab is for importing the txt file and copying the same to choosen attributes with GUI. Now my requirement is , to run script in batch mode with functionality of second tab.Once the script opens it checks Open module ----> GUI mode as usual Not in module (may be from project/folder) ------>run start.bat , in that valid module and the text file to be read should be given and copying of attributes functionality should perform in the module configured in start.bat by reading the text file. I could not find a sample of this function.Please help me To be more clear on my requirement,
if (null current Module) { 1. I don't know how to call batch file from dxl script.What i found in all forums is all about starting a dxl script with a batch file,but i need to know the reverse too for my implementation. 2.In dxl reference also, there is no much information about batch mode :( In start.bat, following details should be pre-configured, 1. Valid module name where copying of attribute values needs to be done 2. Text file location from where attribute values to be copied 3.Log file should be created for capturing all actions done in batch mode with date and time. I am a beginner to Dxl and this is my first script .Kindly help me with your valuable suggestions.
Best Regards, Brindha Hi To start an other script - with different user priviledges - I use WScript.Shell. But be careful if you use it too. You have to encrypt the files to avoid that everone can read the password.
OleAutoObj objStartExtScriptShell = oleCreateAutoObject("WScript.Shell");
OleAutoArgs objStartExtScriptArguments = create();
string sDoorsHome = getenv("HOME");
string sStartExtScriptCommand = sDoorsHome "bin\\doors.exe -W -batch \"" sScriptPathName "\" -user " sXUser " -password " sXPasswort;
clear(objStartExtScriptArguments);
put(objStartExtScriptArguments, sStartExtScriptCommand);
put(objStartExtScriptArguments, 0); // No Window
put(objStartExtScriptArguments, true); // Wait for End of external routine
int iResult = 0;
sErrorMessage = oleMethod(objStartExtScriptShell, "Run", objStartExtScriptArguments, iResult);
And your script does not decide if the current item is a module or a folder. That is the taks of Doors itself. If it is a module you only can start a script in the addins-path and if it is a module you only can start a projectaddins-script. Best regards Wolfgang |
Re: Calling batch file from DXL script brindhaMano - Mon Sep 15 07:22:57 EDT 2014 Hello Mathias, I already found the above thread and it was helpful.But my problem is, I am creating a dxl script with two tabs, one is for choosing the attribute values to be copied to a .txt file and the other tab is for importing the txt file and copying the same to choosen attributes with GUI. Now my requirement is , to run script in batch mode with functionality of second tab.Once the script opens it checks Open module ----> GUI mode as usual Not in module (may be from project/folder) ------>run start.bat , in that valid module and the text file to be read should be given and copying of attributes functionality should perform in the module configured in start.bat by reading the text file. I could not find a sample of this function.Please help me To be more clear on my requirement,
if (null current Module) { 1. I don't know how to call batch file from dxl script.What i found in all forums is all about starting a dxl script with a batch file,but i need to know the reverse too for my implementation. 2.In dxl reference also, there is no much information about batch mode :( In start.bat, following details should be pre-configured, 1. Valid module name where copying of attribute values needs to be done 2. Text file location from where attribute values to be copied 3.Log file should be created for capturing all actions done in batch mode with date and time. I am a beginner to Dxl and this is my first script .Kindly help me with your valuable suggestions.
Best Regards, Brindha It sounds like you want to run a windows batch file. I have done something similar, maybe this code snippet may help
if (platform=="WIN32") { } It starts a command prompt in which you can run the start.bat file. I added the acknowledge so the dxl script will stop until you give the goahead to continue, this would normally be done after you have verified the batch program is completed. Hope this helps, Greg |
Re: Calling batch file from DXL script If your on-demand script generates a list of attributes and a target module, why not just run the code right there? Open that other module edit and create the attributes? |
Re: Calling batch file from DXL script brindhaMano - Mon Sep 15 07:22:57 EDT 2014 Hello Mathias, I already found the above thread and it was helpful.But my problem is, I am creating a dxl script with two tabs, one is for choosing the attribute values to be copied to a .txt file and the other tab is for importing the txt file and copying the same to choosen attributes with GUI. Now my requirement is , to run script in batch mode with functionality of second tab.Once the script opens it checks Open module ----> GUI mode as usual Not in module (may be from project/folder) ------>run start.bat , in that valid module and the text file to be read should be given and copying of attributes functionality should perform in the module configured in start.bat by reading the text file. I could not find a sample of this function.Please help me To be more clear on my requirement,
if (null current Module) { 1. I don't know how to call batch file from dxl script.What i found in all forums is all about starting a dxl script with a batch file,but i need to know the reverse too for my implementation. 2.In dxl reference also, there is no much information about batch mode :( In start.bat, following details should be pre-configured, 1. Valid module name where copying of attribute values needs to be done 2. Text file location from where attribute values to be copied 3.Log file should be created for capturing all actions done in batch mode with date and time. I am a beginner to Dxl and this is my first script .Kindly help me with your valuable suggestions.
Best Regards, Brindha Brindha, It is not very clear as to what you want to do, or where you are having problems with. Maybe it would be more understandable if we also knew the format of the start.bat file. If the dxl script you have is running, then obviously you have DOORS open already. If the script is not running from a module, you can make the script open the start.bat file, read the first line (first line being the path/module name) and open up the module in exclusive edit. Following that, it can read the following lines in the start.bat file and populate the attribute it finds with the data it finds. I wonder if the confusion is thinking the start.bat file needs to open the DOORS module. It shouldn't have to do this and would cause a second instance of DOORS to be started, which then would not know anything about your dxl script in the first instance. Greg |
Re: Calling batch file from DXL script GregM_dxler - Mon Sep 15 16:12:08 EDT 2014 Brindha, It is not very clear as to what you want to do, or where you are having problems with. Maybe it would be more understandable if we also knew the format of the start.bat file. If the dxl script you have is running, then obviously you have DOORS open already. If the script is not running from a module, you can make the script open the start.bat file, read the first line (first line being the path/module name) and open up the module in exclusive edit. Following that, it can read the following lines in the start.bat file and populate the attribute it finds with the data it finds. I wonder if the confusion is thinking the start.bat file needs to open the DOORS module. It shouldn't have to do this and would cause a second instance of DOORS to be started, which then would not know anything about your dxl script in the first instance. Greg Greg, This was exactly for what I am looking for!
if (null current Module) { } } And in start.bat , 1.target module where copying of attributes should happen needs to be predefined 2.Text file path where attributes are selected and saved needs to be predefined. Now I need to open the module pre-defined in start.bat and copying of attributes should happen by reading the text file.And also write log file as follows
Hope I am clear now ! Sorry if I am not clear Regards, Brindha |
Re: Calling batch file from DXL script llandale - Mon Sep 15 13:00:47 EDT 2014 If your on-demand script generates a list of attributes and a target module, why not just run the code right there? Open that other module edit and create the attributes? I have completed both selection of attributes and copying of attributes in seperate tabs .But the requirement I got now is to do copying of attributes in batch mode also when the script is not running from module.
Regards, Brindha |
Re: Calling batch file from DXL script brindhaMano - Tue Sep 16 00:22:47 EDT 2014 I have completed both selection of attributes and copying of attributes in seperate tabs .But the requirement I got now is to do copying of attributes in batch mode also when the script is not running from module.
Regards, Brindha I (and probably others) still do not see exactly why you are calling the batch file from DXL instead of executing the code directly in batch mode or interactive mode ... A proper layout for a DXL script that can be executed in batch mode and interactive mode would look like this:
#include <all necessary libraries>
// This is the function that actually does some work
void doWork (Module m, string some, parameters) {
... do your work here ...
}
// Global GUI Variables
DB gui
DBE ...
Module modCur = current
// This is the GUI callback that executes the 'action'
// Note: You might have several of those
void gui_callback_button_go (DBE) {
string par_some = ... // read the input parameters from the GUI
string par_parameters = // ...
doWork (modCur, par_some, par_parameters)
}
void showGUI() {
gui = centered "My Dialog"
... // create dialog box elements
apply(..., gui_callback_button_go) // Setup your callbacks
show gui
}
// Now comes the main part ...
if (isBatch()) {
// batch mode
// read parameters from environment, global variables, etc.
string par_some = getenv(...)
string par_parameters = getenv(...)
Module mod = read( ... ) // open the right module ...
doWork(mod, par_some, par_parameter)
} else {
// interactive mode ... Show the GUI ...
showGUI()
}
So either you are performing work in interactive mode or in batch mode ... But in no case you would need to call batch mode from interactive mode or vice versa, except in the case where you actually what to perform a non-blocking laborious DOORS operation from a (DOORS) GUI. And with the above approach you also do not need to modify your DXL in any way. So maybe can you tell us WHY you are doing what you are doing (or which problem you are actually trying to solve). Just my two cents, regards, Mathias |